<template>
  <div class="page-banner" :style="bannerStyle">
    <div class="banner-content">
      <div class="banner-text">
        <h1 class="banner-title">{{ title }}</h1>
        <p class="banner-desc">{{ description }}</p>
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from 'vue'

// 定义props
const props = defineProps({
  backgroundImage: {
    type: String,
    default: ''
  },
  backgroundColor: {
    type: String,
    default: '#1a365d'
  },
  title: {
    type: String,
    required: true
  },
  description: {
    type: String,
    default: ''
  },
  height: {
    type: [String, Number],
    default: '300px'
  }
})

// 计算banner样式
const bannerStyle = computed(() => ({
  backgroundImage: props.backgroundImage ? `url(${props.backgroundImage})` : 'none',
  backgroundColor: !props.backgroundImage ? props.backgroundColor : 'transparent',
  height: typeof props.height === 'number' ? `${props.height}px` : props.height
}))
</script>

<style lang="scss" scoped>
.page-banner {
  width: 100%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
  margin-bottom: 40px;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
  }

  .banner-content {
    position: relative;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .banner-text {
    text-align: center;
    color: #fff;
    z-index: 1;

    .banner-title {
      font-size: 48px;
      font-weight: 700;
      margin-bottom: 20px;
      text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    }

    .banner-desc {
      font-size: 20px;
      opacity: 0.9;
      text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
      max-width: 800px;
      margin: 0 auto;
    }
  }

  @media (max-width: 768px) {
    height: 200px !important;

    .banner-text {
      .banner-title {
        font-size: 32px;
        margin-bottom: 10px;
      }

      .banner-desc {
        font-size: 16px;
      }
    }
  }
}
</style> 